/*
 * 文 件 名:  test.java
 * 版    权:   深圳埃思欧纳信息咨询有限公司版权所有. YYYY-YYYY,  All rights reserved
 * 描    述:   <描述>
 * 修 改 人:  honny.huang
 * 修改时间: 2010-10-12
 * 跟踪单号:  <跟踪单号>
 * 修改单号:  <修改单号>
 * 修改内容:  <修改内容>
 */
package com.common;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;


/**
 * <从指定路径读取文件并将文件流转换成 特定格式的string字符串> <功能详细描述>
 *
 * @author honny.huang
 * @version [版本号, 2010-10-12]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */

public class ParticularFormatString 
{

	 public void convertChinaHRArea()
     {
        String chinaHRPath = "E:\\Workspaces\\test\\WebRoot\\listID.txt";
        this.getChinaHRAreaList(chinaHRPath);
     }
	 
	 /**
	  * 读取路径文件并转化成输入流
	  * <功能详细描述>
	  * @param filePath
	  * @return
	  * 
	  * @return String [返回类型说明]
	  * @exception throws [违例类型] [违例说明]
	  * @see [类、类#方法、类#成员]
	  */
	 public String getChinaHRAreaList(String filePath)
	 {
	      File file = new File(filePath);
	      InputStream is = null;
	      try
	      {
	          is = new FileInputStream(file);
	      }
	      catch (FileNotFoundException e)
	      {
	          e.printStackTrace();
	      }
	      String areaTemp = this.convertToString(is);
	      System.out.print("============");
	      System.out.print(areaTemp);
	      System.out.print("=============");
	      return areaTemp;
	  }
	 
	 /**
	  * 将文件输入流转换成string字符串
	  * <功能详细描述>
	  * @param is
	  * @return
	  * 
	  * @return String [返回类型说明]
	  * @exception throws [违例类型] [违例说明]
	  * @see [类、类#方法、类#成员]
	  */
	 public String convertToString(InputStream is)
	 {
	        StringBuffer buffer = new StringBuffer();
	        try
	        {
	            BufferedReader in = new BufferedReader(new InputStreamReader(is));
	            String line = "";
	            while ((line = in.readLine()) != null)
	            {
	            	String line2 = in.readLine();
	            	System.out.print(line2);
	            	// 对读出的数据做加‘’处理，以,分割
	            	line = "'"+in.readLine()+"'";
	                buffer.append(line+",");
	            }
	        }
	        catch (Exception e)
	        {
	            e.printStackTrace();
	        }
	        return buffer.toString();
	    }
	 
	 // 调试
	 public static void main(String[] ar)
	 {
	    ParticularFormatString testlist = new ParticularFormatString();
	    testlist.convertChinaHRArea();
	 }
}
